package com.nextive.weightlogger.activity;

import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;

import com.nextive.weightlogger.MenuManager;

/**
 * Abstract activity that creates the default options menu for this application
 * and handles the options menu item selection.
 * 
 * @author Federico Baseggio <fedebaseggio@gmail.com>
 */
public abstract class BaseActivity extends Activity {
	/**
	 * Boolean intent extra field indicating if this activity was started as the
	 * first activity in the flow.
	 */
	public static final String INTENT_EXTRA_FIRST_ACTIVITY = 
		"INTENT_EXTRA_FIRST_ACTIVITY";

	private MenuManager menuManager;
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		menuManager = new MenuManager(this);
	    return menuManager.onCreateOptionsMenu(menu);
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item)
	{
		if (menuManager.onOptionsItemSelected(item))
		{
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
